package weblech.ui;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.util.Properties;

import org.apache.log4j.Category;

import weblech.spider.Spider;
import weblech.spider.SpiderConfig;

public class Main {
	private static Category _logClass = Category.getInstance(Main.class);

	public static void main(String asd[]){
		Main main =new Main();
		main.init();
	}
	private void init(){
		 Properties props = null;
	        try{
	        	InputStream in = getClass().getClassLoader().getResourceAsStream("Spider.properties"); 
//	            FileInputStream propsIn = new FileInputStream("Spider.properties");
	            props = new Properties();
	            props.load(in);
	            in.close();
	        }
	        catch(FileNotFoundException fnfe)
	        {
	            _logClass.error("File not found: ", fnfe);
	            System.exit(1);
	        }
	        catch(IOException ioe)
	        {
	            _logClass.error("IO Exception caught reading config file: " + ioe.getMessage(), ioe);
	            System.exit(1);
	        }
		SpiderConfig config = new SpiderConfig(props);
		Spider spider;
		try {
			spider = new Spider(config);
			spider.start();
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
}
